package com.lvhr.example.consumer;
import com.lvhr.example.common.model.User;
import com.lvhr.example.common.service.UserService;
import com.lvhr.rpc.proxy.ServiceProxy;
import com.lvhr.rpc.proxy.ServiceProxyFactory;

/**
 * 简易消费者
 */
public class EasyConsumerExample {
    public static void main(String[] args) {
        // todo 需要获取 UserService 的实现类对象
        //静态代理
//        UserService userService = new UserServiceProxy();

        //动态代理
        UserService userService= ServiceProxyFactory.getProxy(UserService.class);
//        UserService userService = null;
        User user = new User();
        user.setName("lvhr");
        //调用
        User newUser = userService.getUser(user);

        if (newUser != null) {
            System.out.println(newUser.getName());
        } else {
            System.out.println("user == null");
        }
    }

}
